// import request from '@/utils/request'
import request from "../utils/request";
export default {
	//查询acount列表
	findAll() {
		return new Promise((resolve, reject) => {
			return request({
					url: "/accountRest/findAll",
					method: "get"
				})
				.then(response => {
					resolve(response);
				})
				.catch(error => {
					reject(error);
				});
		});
	},
	//添加
	add(fromData) {
		return new Promise((resolve, reject) => {
			return request({
					url: "/accountRest/add",
					method: "post",
					data:fromData
				})
				.then(response => {
					resolve(response);
				})
				.catch(error => {
					reject(error);
				});
		});
	},
	//停用
	stop(fromData) {
		return new Promise((resolve, reject) => {
			return request({
					url: "/accountRest/stop?aid="+fromData,
					method: "get"
				})
				.then(response => {
					resolve(response);
				})
				.catch(error => {
					reject(error);
				});
		});
	},
	//编辑
	edit(fromData) {
		return new Promise((resolve, reject) => {
			return request({
					url: "/accountRest/update",
					method: "post",
					data:fromData
				})
				.then(response => {
					resolve(response);
				})
				.catch(error => {
					reject(error);
				});
		});
	},
	//删除
	del(fromData) {
		return new Promise((resolve, reject) => {
			return request({
					url: "/accountRest/delete?aid="+fromData,
					method: "get"
				})
				.then(response => {
					resolve(response);
				})
				.catch(error => {
					reject(error);
				});
		});
	},
	//余额
	findBalance(fromData) {
		return new Promise((resolve, reject) => {
			return request({
					url: "/balance/find?aid="+fromData,
					method: "get"
				})
				.then(response => {
					resolve(response);
				})
				.catch(error => {
					reject(error);
				});
		});
	},
	//账户收入
	income(data){
		return new Promise((resolve, reject) => {
			return request({
					url: "/api/account/income",
					method: "post",
					data:data
				})
				.then(response => {
					resolve(response);
				})
				.catch(error => {
					reject(error);
				});
		});
	},
	//账户支出
	pay(data){
		return new Promise((resolve, reject) => {
			return request({
					url: "/api/account/pay",
					method: "post",
					data:data
				})
				.then(response => {
					resolve(response);
				})
				.catch(error => {
					reject(error);
				});
		});
	},
	//账户转移
	transfer(data){
		return new Promise((resolve, reject) => {
			return request({
					url: "/api/account/transfer",
					method: "post",
					data:data
				})
				.then(response => {
					resolve(response);
				})
				.catch(error => {
					reject(error);
				});
		});
	},
	getHome(){
		return new Promise((resolve, reject) => {
			return request({
					url: "/accountRest/getHome",
					method: "get"
				})
				.then(response => {
					resolve(response);
				})
				.catch(error => {
					reject(error);
				});
		});
	}
}
